package com.yy.finvideoplayer.renderview

import android.graphics.Bitmap
import android.view.Surface
import android.view.SurfaceHolder
import android.view.View
import com.yy.finvideoplayer.media.IMediaControl

/**
 * 接口化渲染view
 * @Description: IRenderView
 * @Author: yiw89
 * @CreateDate: 2025/9/1 14:51
 * @Version: 1.0
 */
interface IRenderView {
    //boolean shouldWaitForResize();
    fun get(): View?

    fun setVideoSize(videoWidth: Int, videoHeight: Int)


    //void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
    fun setVideoRotation(degree: Int)

    fun setAspectRatio(aspectRatio: Int)

    fun addRenderCallback(callback: IRenderCallback?)

    fun removeRenderCallback()

    fun getSurfaceHolder(): SurfaceHolder?

    fun openSurface(): Surface?

    fun bindMedia(iMediaControl: IMediaControl)

    fun getCurrentFrame(): Bitmap? //截图

    interface IRenderCallback {
        fun onSurfaceCreated(holder: IRenderView, width: Int, height: Int)

        fun onSurfaceChanged(holder: IRenderView, format: Int, width: Int, height: Int)

        fun onSurfaceDestroyed(holder: IRenderView)
    }

    companion object {
        const val AR_ASPECT_FIT_PARENT: Int = 0 //适应 根据视频大小缩放 至少一边填充屏幕 *默认  contain
        const val AR_ASPECT_FILL_PARENT: Int = 1 //填充 根据视频大小缩放 完全填充屏幕   cover
        const val AR_ASPECT_WRAP_CONTENT: Int = 2 //原画
        const val AR_MATCH_PARENT: Int = 3 //拉伸 强制全屏 比例不对会变形   fill
        const val AR_16_9_FIT_PARENT: Int = 4 //强制16:9 适应屏幕 比例不对会变形
        const val AR_4_3_FIT_PARENT: Int = 5 //强制4:3 适应屏幕 比例不对会变形
    }
}